//
//  BLAnnounceView.m
//  weather
//
//  Created by 大L君的无敌战舰 on 16/4/10.
//  Copyright © 2016年 bigL.com. All rights reserved.
//

#import "BLWeatherAnnounceView.h"

@interface BLWeatherAnnounceView ()
/* 天气描述 */
@property (strong, nonatomic) UILabel * describe;
/* 天气描述 */
@property (strong, nonatomic) UILabel * temperature;
/* 风向图标 */
@property (strong, nonatomic) UIImageView *windDirectionImageView;
/* 风速描述 */
@property (strong, nonatomic) UILabel * windSpeed;
/* 预报图标 */
@property (strong, nonatomic) UIImageView *forecastImageView;
/* 预报描述 */
@property (strong, nonatomic) UILabel * forecast;
/* 箭头图标 */
@property (strong, nonatomic) UIImageView *arrowImageView;


@end

@implementation BLWeatherAnnounceView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //加载子控件
        [self setChildView];
        //加载数据
        [self loadData];
    }
    return self;
}


//加载子控件
-(void)setChildView
{
    //天气描述
    UILabel * describe = [[UILabel alloc]init];
    describe.font = TextMidSize;
    self.describe = describe;
    [self addSubview:describe];
    //约束
    [describe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(5);
        make.top.equalTo(self).with.offset(0);
        make.height.equalTo(self.mas_height).multipliedBy(0.25);
    }];
    
    
    //温度描述
    UILabel * temperature = [[UILabel alloc]init];
    temperature.font = TextBigSize;
    self.temperature = temperature;
    [self addSubview:temperature];
    //约束
    [temperature mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(5);
        make.top.equalTo(self.describe.mas_bottom).with.offset(0);
        make.height.equalTo(self.mas_height).multipliedBy(0.5);

    }];
    
    
    //风向图标
    UIImageView *windDirectionImageView = [[UIImageView alloc]init];
    self.windDirectionImageView         = windDirectionImageView;
    [self addSubview:windDirectionImageView];
    //约束
    [windDirectionImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).with.offset(0);
        make.top.equalTo(self.temperature.mas_bottom).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.15);
        make.height.equalTo(self.mas_height).multipliedBy(0.25);
        make.bottom.equalTo(self).with.offset(0);
    }];
    
    
    //风速描述
    UILabel * windSpeed = [[UILabel alloc]init];
    windSpeed.font = TextSmallSize;
    self.windSpeed = windSpeed;
    [self addSubview:windSpeed];
    //约束
    [windSpeed mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.windDirectionImageView.mas_right).with.offset(0);
        make.top.equalTo(self.temperature.mas_bottom).with.offset(0);
        make.bottom.equalTo(self).with.offset(0);
    }];
    
    
    //预报图标
    UIImageView *forecastImageView = [[UIImageView alloc]init];
    self.forecastImageView         = forecastImageView;
    [self addSubview:forecastImageView];
    //约束
    [forecastImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.windSpeed.mas_right).with.offset(0);
        make.top.equalTo(self.temperature.mas_bottom).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.15);
        make.bottom.equalTo(self).with.offset(0);
    }];
    
    
    //预报描述
    UILabel * forecast = [[UILabel alloc]init];
    forecast.font      = TextSmallSize;
    self.forecast      = forecast;
    [self addSubview:forecast];
    //约束
    [forecast mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.forecastImageView.mas_right).with.offset(0);
        make.top.equalTo(self.temperature.mas_bottom).with.offset(0);
        make.bottom.equalTo(self).with.offset(0);
    }];
    
    
    
    //箭头图标
    UIImageView *arrowImageView = [[UIImageView alloc]init];
    self.arrowImageView         = arrowImageView;
    [self addSubview:arrowImageView];
    //约束
    [arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).with.offset(0);
        make.top.equalTo(self.temperature.mas_bottom).with.offset(0);
        make.width.equalTo(self.mas_width).multipliedBy(0.15);
        make.bottom.equalTo(self).with.offset(0);
    }];
    
    
    
    
    
    
}


//加载数据
- (void)loadData
{
    self.describe.text    = @"阴";
    self.temperature.text = @"22°";
    self.windSpeed.text   = @"1级";
    self.forecast.text    = @"明天有雨";
    
    self.describe.textColor    = [UIColor whiteColor];
    self.temperature.textColor = [UIColor whiteColor];
    self.windSpeed.textColor   = [UIColor whiteColor];
    self.forecast.textColor    = [UIColor whiteColor];
    
//    self.describe.backgroundColor    = BLRandomColor(1);
//    self.temperature.backgroundColor = BLRandomColor(1);
//    self.windSpeed.backgroundColor   = BLRandomColor(1);
//    self.forecast.backgroundColor    = BLRandomColor(1);
    
    
    self.arrowImageView.backgroundColor         = BLRandomColor(2);
    self.windDirectionImageView.backgroundColor = BLRandomColor(2);
    self.forecastImageView.backgroundColor      = BLRandomColor(2);
    
    
    
}
@end
